import { createRouter, createWebHistory } from "vue-router";
import { staticRoutes } from "./routers";
// import { useAppStore } from '../store/user'
// const userStore =  useAppStore()
const router = createRouter({
  history: createWebHistory(),
  routes: staticRoutes,
  // 滚动行为：当路由组件切换时滚动条的位置
  scrollBehavior() {
    return { top: 0, left: 0 };
  },
});

// const PATHS = ['/order',"/shopping","/settlement"]
// router.beforeEach((to,from,next)=>{
//   if(userStore.userName){
//     //已经登录
//     next()
//   }else{
//     //未登录
//     //判断是否去权限页面
//     console.log(PATHS.includes(to.path));
//     if(PATHS.includes(to.path)){
//       //跳转到登录页
//       next(`/login?redirect=${to.path}`)
//     }else{
//       //不是去权限页面直接放行
//       next()
//     }
//   }
// })

// 导出路由
export default router;
